<?php
namespace app\admin\controller;
use app\model\User as UserModel;
use think\Db;


class Index extends Base
{
    public function index()
    {
        $page_info = $this->page_info;
        $page_info['title'] = '首页';

        $menu_list = Db::name('menu')->where([
            ['pid','=',0]
        ])->select();
        foreach ($menu_list as $k => $vo) {
            if (!empty($vo['role']) && !roleCheck(explode(',',$vo['role']))) {
                unset($menu_list[$k]);
                continue;
            }
            $childs = Db::name('menu')->where([
                ['pid','=',$vo['id']]
            ])->select();
            foreach ($childs as $child_k => $child_v) {
                if (!empty($child_v['role']) && !roleCheck(explode(',',$child_v['role']))) {
                    unset($childs[$child_k]);
                    continue;
                }
                $childs[$child_k]['childs'] = Db::name('menu')->where([
                    ['pid','=',$child_v['id']]
                ])->select();
            }
            $menu_list[$k]['childs'] = $childs;
        }

        return view('index', [
            'page_info'=>$page_info,
            'menu_list'=>$menu_list
        ]);
    }

    public function main(){
        return view('main', [
            
        ]);
    }

    public function prompt($msg=''){
        return view('prompt', [
            'msg'=>$msg,
        ]);
    }

    

   
}
